package com.ncloud.billing.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.ncloud.billing.entity.BsDiscntFee;

@Mapper
public interface BsDiscntFeeMapper {
	
	@Select(value = {"SELECT cust_id, discnt_inst_id, discnt_id, discnt_name, fee_type, fee_code, pay_type, ifnull(received_fee,0) as received_fee, "
			+ "ifnull(pay_fee,0) as pay_fee, ifnull(balance,0) as balance, ifnull(standard,0) as standard,"
			+ "billing_cycle, cycle_unit, begin_date, end_date, create_user, create_time, "
			+ "ifnull(fee_value,0) as fee_value, ifnull(fee_value2,0) as fee_value2, str_value, str_value2  "
			+ "FROM bs_discnt_fee where cust_id = #{0} and discnt_inst_id = #{1} "})
	@Results({ @Result(column = "cust_id", property = "cust_id"), @Result(column = "discnt_inst_id", property = "discnt_inst_id"),
         @Result(column = "discnt_id", property = "discnt_id"),@Result(column = "discnt_name", property = "discnt_name"),
         @Result(column="fee_type",property="fee_type"),@Result(column="fee_code",property="fee_code"),
         @Result(column="pay_type",property="pay_type"),@Result(column="received_fee",property="received_fee"),
         @Result(column="pay_fee",property="pay_fee"),@Result(column="balance",property="balance"),
         @Result(column="standard",property="standard"),@Result(column="billing_cycle",property="billing_cycle"),
         @Result(column="cycle_unit",property="cycle_unit"),@Result(column="begin_date",property="begin_date"),
         @Result(column="end_date",property="end_date"),
         @Result(column="create_user",property="create_user"),@Result(column="create_time",property="create_time"),
         @Result(column="fee_value",property="fee_value"),@Result(column="fee_value2",property="fee_value2"),
         @Result(column="str_value",property="str_value"),@Result(column="str_value2",property="str_value2")})
	public List<BsDiscntFee> getBsDiscntFeeByDiscntInstID(Long cust_id,Long discnt_inst_id);
	
	@Update(value = {"UPDATE bs_discnt_fee SET fee_value = #{fee_value} WHERE cust_id = #{cust_id} and discnt_inst_id = #{discnt_inst_id} "})
	public int updateDiscntFeeValue(BsDiscntFee bsDiscntFee);
} 